from Page.Page2 import Page2
from selenium.webdriver.common.by import By

class Page4(Page2):
    address_loc = (By.XPATH,'/html/body/div[5]/div[1]/div[2]/div[4]/div[2]/ul/li[1]/a')
    def address(self):
        self.click(self.address_loc)

    dy5_loc = (By.XPATH,'/html/body/div[5]/div[2]/div/div[1]/span')
    def dy5(self):
        dy5 = self.text(self.dy5_loc)
        print(dy5)

    add_address_loc = (By.XPATH,'/html/body/div[5]/div[2]/div/div[1]/a')
    def add_address(self):
        self.click(self.add_address_loc)

    sheng_loc = (By.XPATH,'/html/body/div[9]/div[2]/div/div/form/div[1]/div[1]/div/div/input')
    def sheng(self):
        self.click(self.sheng_loc)

    sheng_xuan_loc = (By.XPATH,'/html/body/div[9]/div[2]/div/div/form/div[1]/div[1]/div/dl/dd[2]')
    def sheng_xuan(self):
        self.click(self.sheng_xuan_loc)

    shi_loc = (By.XPATH,'//*[@id="layui-layer3"]/div[2]/div/div/form/div[1]/div[2]/div/div/input')
    def shi(self):
        self.click(self.shi_loc)

    shi_xuan_loc = (By.XPATH,'/html/body/div[9]/div[2]/div/div/form/div[1]/div[2]/div/dl/dd[2]')
    def shi_xuan(self):
        self.click(self.shi_xuan_loc)

    qu_loc = (By.XPATH,'//*[@id="layui-layer3"]/div[2]/div/div/form/div[1]/div[3]/div/div/input')
    def qu(self):
        self.click(self.qu_loc)

    qu_xuan_loc = (By.XPATH,'//*[@id="layui-layer3"]/div[2]/div/div/form/div[1]/div[3]/div/dl/dd[12]')
    def qu_xuan(self):
        self.click(self.qu_xuan_loc)

    name_loc = (By.NAME,'accept_name')
    def name(self):
        self.send_keys(self.name_loc,'余凯文')

    phone_loc = (By.NAME,'mobile')
    def phone(self):
        self.send_keys(self.phone_loc,'18620064667')

    stret_loc = (By.NAME,'address')
    def stret(self):
        self.send_keys(self.stret_loc,'南口街道')

    submit_loc = (By.CLASS_NAME,'layui-btn')
    def submit(self):
        self.click(self.submit_loc)

    def luoji_A3mall_address(self):
        try:
            self.luoji_A3mall_login()
            self.sleep(5)
            self.scrollTo_x(1000)
            self.implicitly_wait(10)
            self.address()
            self.dy5()
            self.add_address()
            self.sleep(2)
            # self.sheng()
            # self.sheng_xuan()
            # self.sleep(1)
            # self.shi()
            # self.shi_xuan()
            # self.sleep(1)
            # self.qu()
            # self.qu_xuan()
            self.name()
            self.phone()
            self.stret()
            self.submit()
            self.sleep(1)
        except Exception as e:
            print(e)
            self.screenshot()